package logging;

import java.util.Date;

/**
 * 为了方便的管理输出内容，现在需要创建一个输出内容的类来封装这些信息：
 * @author Zhongzhicong
 * @date 2023/3/22 15:53
 * @version：1.0
 */
public class LoggingEvent {
    public long timestamp;//日志时间戳
    public int levelInt;//日志级别
    public Level level;//日志级别
    public String message;//日志主题信息
    public String threadName;//线程名称
    public long threadId;//线程id
    public String loggerName;//日志名称

    public LoggingEvent(Level level, String msg, String name) {
        this.level = level;
        this.levelInt = level.toInt();
        this.message = msg;
        this.loggerName = name;
        this.timestamp = new Date().getTime();
        Thread thread = Thread.currentThread();
        this.threadId = thread.getId();
        this.threadName = thread.getName();
    }

    @Override
    public String toString() {
        return "LoggingEvent{" +
                "timestamp=" + timestamp +
                ", level=" + level +
                ", message=" + message +
                ", threadName='" + threadName + '\'' +
                ", threadId=" + threadId +
                ", loggerName='" + loggerName + '\'' +
                '}';
    }
}
